home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / syscall / RCS / Fs_WriteVector.c,v < prev    next >
Encoding:
Text File  |  1991-12-09  |  4.3 KB  |  208 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.5.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     88.07.29.17.08.39;  author ouster;  state Exp;
  11. branches 1.5.1.1;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     88.07.25.11.15.22;  author ouster;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.07.01.14.02.04;  author ouster;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.06.21.11.18.07;  author ouster;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.06.19.14.29.16;  author ouster;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34. 1.5.1.1
  35. date     91.12.08.17.07.04;  author kupfer;  state Exp;
  36. branches ;
  37. next     ;
  38.  
  39.  
  40. desc
  41. @@
  42.  
  43.  
  44. 1.5
  45. log
  46. @Lint.
  47. @
  48. text
  49. @/* 
  50.  * Fs_WriteVector.c --
  51.  *
  52.  *    Source code for the Fs_WriteVector library procedure.
  53.  *
  54.  * Copyright 1988 Regents of the University of California
  55.  * Permission to use, copy, modify, and distribute this
  56.  * software and its documentation for any purpose and without
  57.  * fee is hereby granted, provided that the above copyright
  58.  * notice appear in all copies.  The University of California
  59.  * makes no representations about the suitability of this
  60.  * software for any purpose.  It is provided "as is" without
  61.  * express or implied warranty.
  62.  */
  63.  
  64. #ifndef lint
  65. static char rcsid[] = "$Header: Fs_WriteVector.c,v 1.4 88/07/25 11:15:22 ouster Exp $ SPRITE (Berkeley)";
  66. #endif not lint
  67.  
  68. #include <sprite.h>
  69. #include <fs.h>
  70. #include <status.h>
  71. #include <stdlib.h>
  72.  
  73.  
  74. /*
  75.  *----------------------------------------------------------------------
  76.  *
  77.  * Fs_WriteVector --
  78.  *
  79.  *      The "normal" Fs_WriteVector routine for user code.  Write to the file
  80.  *      indicated by the stream ID from the buffers described in vectorArray.
  81.  *    The vectorArray indicates how much data to write, and amtWrittenPtr 
  82.  *    is an output parameter that indicates how much data were written.  
  83.  *
  84.  *    Restarting from a signal is automatically handled by Fs_Write.
  85.  *
  86.  * Results:
  87.  *    Result from Fs_Write.
  88.  *
  89.  * Side effects:
  90.  *    See Fs_Write.
  91.  *
  92.  *----------------------------------------------------------------------
  93.  */
  94.  
  95. ReturnStatus
  96. Fs_WriteVector(streamID, numVectors, vectorArray, amtWrittenPtr)
  97.     int         streamID;    /* The user's index into its open file list. */
  98.     int         numVectors;    /* The # of vectors in userVectorArray. */
  99.     Fs_IOVector vectorArray[];    /* The vectors defining where and how much to
  100.                  * write. */
  101.     int        *amtWrittenPtr;    /* The amount of bytes actually written. */
  102. {
  103.     register int     i;
  104.     register Fs_IOVector *vectorPtr;
  105.     register int    bufSize;
  106.     Address        buffer;
  107.     Address        ptr;
  108.     ReturnStatus    status;
  109.  
  110.     /*
  111.      * Calculate the total number of bytes to be write.
  112.      */
  113.     bufSize = 0;
  114.     for (i = 0, vectorPtr = vectorArray; i < numVectors; i++, vectorPtr++) {
  115.     if (vectorPtr->bufSize < 0) {
  116.         return SYS_INVALID_ARG;
  117.     }
  118.     bufSize += vectorPtr->bufSize;
  119.     }
  120.     buffer = (Address) malloc((unsigned) bufSize);
  121.  
  122.     /*
  123.      * Copy the data from the individual buffers specified in the 
  124.      * vectorArray to the big buffer so the data can be written all at
  125.      * once.
  126.      */
  127.     ptr = buffer;
  128.     for (i = 0, vectorPtr = vectorArray; i < numVectors; i++, vectorPtr++) {
  129.     bcopy(vectorPtr->buffer, ptr, vectorPtr->bufSize);
  130.     ptr += vectorPtr->bufSize;
  131.     }
  132.  
  133.     status = Fs_Write(streamID, bufSize, buffer, amtWrittenPtr);
  134.     free((char *) buffer);
  135.     return(status);
  136. }
  137. @
  138.  
  139.  
  140. 1.5.1.1
  141. log
  142. @Initial branch for Sprite server.
  143. @
  144. text
  145. @d17 1
  146. a17 1
  147. static char rcsid[] = "$Header: /sprite/src/lib/c/syscall/RCS/Fs_WriteVector.c,v 1.5 88/07/29 17:08:39 ouster Exp $ SPRITE (Berkeley)";
  148. @
  149.  
  150.  
  151. 1.4
  152. log
  153. @Lint.
  154. @
  155. text
  156. @d17 1
  157. a17 1
  158. static char rcsid[] = "$Header: Fs_WriteVector.c,v 1.3 88/07/01 14:02:04 ouster Exp $ SPRITE (Berkeley)";
  159. d72 1
  160. a72 1
  161.     buffer = (Address) malloc(bufSize);
  162. @
  163.  
  164.  
  165. 1.3
  166. log
  167. @Remove calls to Stat_Error:  they aren't needed anymore.
  168. @
  169. text
  170. @d17 1
  171. a17 1
  172. static char rcsid[] = "$Header: Fs_WriteVector.c,v 1.2 88/06/21 11:18:07 ouster Exp $ SPRITE (Berkeley)";
  173. d23 1
  174. a23 6
  175.  
  176. /*
  177.  * Library imports:
  178.  */
  179.  
  180. extern char *malloc();
  181. @
  182.  
  183.  
  184. 1.2
  185. log
  186. @Must include status.h.
  187. @
  188. text
  189. @d17 1
  190. a17 1
  191. static char rcsid[] = "$Header: Fs_WriteVector.c,v 1.1 88/06/19 14:29:16 ouster Exp $ SPRITE (Berkeley)";
  192. d73 1
  193. a73 1
  194.         return Stat_Error(SYS_INVALID_ARG);
  195. @
  196.  
  197.  
  198. 1.1
  199. log
  200. @Initial revision
  201. @
  202. text
  203. @d17 1
  204. a17 1
  205. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  206. d22 1
  207. @
  208.